package com.heima.wemedia.client;

import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 黄晏凯
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelClient {

    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 查询频道列表
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto) {
        return wmChannelService.list(dto);
    }

    /**
     * 新增频道
     *
     * @param wmChannel wm通道
     * @return {@link ResponseResult}
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.saveChannel(wmChannel);
    }

    /**
     * 修改频道
     *
     * @param wmChannel wm通道
     * @return {@link ResponseResult}
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.updateChannel(wmChannel);
    }

    /**
     * 删除频道
     *
     * @param id id
     * @return {@link ResponseResult}
     */
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id) {
        return wmChannelService.deleteChannel(id);
    }

}
